package cn.yhp.mybatis.executor.statement;

import cn.yhp.mybatis.session.ResultHandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

/**
 * 语句处理器
 * @author yhp
 * @date 2023/12/2
 */
public interface StatementHandler {

    /**
     * 预编译语句
     * @param connection
     * @return
     * @throws SQLException
     */
    Statement prepare(Connection connection) throws SQLException;

    /**
     * 参数化，设置参数值
     * @param statement
     * @throws SQLException
     */
    void parameterize(Statement statement) throws SQLException;

    /**
     * 查询
     * @param statement
     * @param resultHandler
     * @param <E>
     * @return
     */
    <E> List<E> query(Statement statement, ResultHandler resultHandler) throws SQLException;

}
